const { db, query } = require("../../db/db");
const util = require("util");

async function GetAdvertisementList(req, res) {
  const select_GetAdvertisementList_list_sql = util.format(
    "Select \
    AdvertisementId,\
    IsValid,\
    IFNULL(CreateTime,'') as CreateTime, \
    IFNULL(CreateUser,'') as CreateUser, \
    IFNULL(AdvertisementUrl,'') as AdvertisementUrl, \
    IFNULL(AdvertisementImgUrl,'') as AdvertisementImgUrl \
    From Advertisement\
    Limit 5"
  );

  const select_GetAdvertisementList_list_res = await query(
    select_GetAdvertisementList_list_sql
  );
  res.send({
    status: 0,
    AdvertisementList: select_GetAdvertisementList_list_res,
  });
}

module.exports = { GetAdvertisementList };
